<template>
  <div>
    <MkBillPanel ref='billPanelRef' printCode='InvTuiXue' :bill="ctx.zhuBiao" id="billPanelRef">
      <template #button>
        <MkButtonQueryHistory @click="listRef.open()" />
        <MkButtonAdd @click="newZhuBiao" :isEdit='ctx.isEdit' />
        <MkButtonSubmit @click="submit" :loading="ctx.loading" :isEdit="ctx.isEdit" />
        <MkButtonMore>
          <!-- <a-menu-item @click="cancel">作废</a-menu-item> -->
          <a-menu-item @click="billPanelRef.showCaoZuo()">操作记录</a-menu-item>
        </MkButtonMore>
        <MkButtonMore title="打印" icon="ele-Printer">
          <a-menu-item>
            <el-button v-print="{ id: 'billPanelRef' }" type="text">打印</el-button>
          </a-menu-item>
        </MkButtonMore>
      </template>
      <template #info>
        <MkForm :model='ctx.zhuBiao' ref='formRef' formId='InvTuiXue' :col="3">
          <MkInput label='退血原因' v-model='ctx.zhuBiao.tuiXueYuanYin' prop='tuiXueYuanYin' :isEdit='ctx.isEdit'
            :col="2" />
        </MkForm>
      </template>
      <MkPanel title="血液信息">
        <MkXueYeScanInput ref="scanRef" @onEnter="scanEnter" width="400px" scanInpWidth="400px" v-if="ctx.isEdit" />
        <MkTable :data="ctx.xueYeList">
          <MkColumnIndex />
          <MkColumnXueYe />
          <MkColumnNumber prop="jiaGe" label="价格" width="80px" />
          <MkColumn prop="caiXueShiJian" label="采血时间" min-width="140px" />
          <el-table-column label="操作" width="120px" fixed="right" v-if="ctx.isEdit">
            <template #default="{ row }">
              <el-button icon="ele-Delete" size="small" text type="danger" @click="deleteBlood(row)">删除</el-button>
            </template>
          </el-table-column>
        </MkTable>
      </MkPanel>
    </MkBillPanel>
    <ListPage ref='listRef' @load='loadEntity' />
  </div>
</template>

<script lang='ts' setup>
import ListPage from './list.vue';
import {
  ctx,
  billPanelRef,
  formRef,
  listRef,
  newZhuBiao,
  loadEntity,
  submit,
  cancel,
  scanEnter,
  deleteBlood
} from './index'
</script>

<style lang='scss' scoped></style>